<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:include   page="common/header.jsp" flush="true">
    <jsp:param name="title" value="犯罪嫌疑人" /> 
</jsp:include>
	<!-- 左侧 -->
	<jsp:include page="common/left.jsp" flush="true" />

	<!-- 右侧 -->
	<div class="crime-page">
		<div class="container-fluid">
			<div class="row">
				<div class="col-lg-12">
					<div class="panel">
						<div class="panel-heading">
							<div class="row">
								<span class="crime-heading-icon"></span> <span class="text">犯罪嫌疑人</span>
							</div>
						</div>
						<div class="panel-body">
							<div class="panel-body-title clearfix">
								<div class="left fl">
									<form action="${basePath }/wxUserlistAction_list" method="post">
										<div class="check-wrapper">
											<div class="check-name">
												<!-- <input type="radio" name="check-answer" /> -->
												<!-- <label for=""></label> -->
												<span>按姓名查找</span> <input type="text" name="truenamestr"
													value="${truenamestr }" placeholder="请输入完整姓名" />
											</div>
											<div class="check-id">
												<!-- <input type="radio" name="check-answer" /> -->
												<!-- <label class="checked" for=""></label> -->
												<span>按证件号码查找</span> <input type="text" name="idcardnostr"
													value="${idcardnostr }" placeholder="请输入证件号" />
											</div>
											<button class="crime-title-search"></button>
										</div>
									</form>
								</div>
								<div class="right fr">
									<a href="javascript:;" class="crime-search-btn"></a>
								</div>
							</div>
							<div class="row">
								<div class="col-lg-6">
									<div class="table-responsive">
										<form action="">
											<table class="table table-bordered table-hover">
												<thead>
													<tr>
														<th style="display: none;"></th>
														<th>序号</th>
														<th>姓名</th>
														<th>性别</th>
														<th>年龄</th>
														<th>证件类型</th>
														<th>证件号码</th>
														<th>操作</th>
													</tr>
												</thead>
												<tbody>
													<c:if test="${not empty wxUserlist}">
														<c:forEach items="${wxUserlist}" var="wxUser"
															varStatus="status">
															<tr>
																<td class="first-hook" style="display: none;"><input
																	type="hidden" value="${wxUser.id}" /></td>
																<td>${status.index+1}</td>
																<td>${wxUser.truename}</td>
																<td><c:if test="${wxUser.sex eq 1}">男</c:if> <c:if
																		test="${wxUser.sex eq 2}">女</c:if></td>
																<td>${wxUser.age}</td>
																<td><c:forEach items="${credtypes}" var="credtype"
																		varStatus="st">
																		<c:if test="${st.index eq wxUser.credtype}">
                                                   	    					${credtype}
                                                   	    				</c:if>
																	</c:forEach></td>
																<td>${wxUser.idcardno}</td>
																<td><a href="javascript:void(0)" id="crime-edit"><span
																		class="glyphicon glyphicon-edit" aria-hidden="true"></span></a>
																	<a href="javascript:void(0)" id="crime-delete"
																	onclick="delUser('${wxUser.id }')"><span
																		class="glyphicon glyphicon-remove-circle"
																		aria-hidden="true"></span></a></td>
															</tr>
														</c:forEach>
													</c:if>
												</tbody>
											</table>
										</form>

										<!-- 分页 -->
										<div class="page">
											<div class="left fl">
												<a
													href="${basePath }/wxUserlistAction_findAll.action?currentPage=1">首页</a>
												<c:forEach begin="1" end="${pageBean.totalPage }"
													varStatus="status">
													<c:if test="${status.count == pageBean.currentPage}">
														<a
															href="${basePath }/wxUserlistAction_findAll.action?currentPage=${status.count }"
															class="active">${status.count }</a>
													</c:if>
													<c:if test="${status.count != pageBean.currentPage}">
														<a
															href="${basePath }/wxUserlistAction_findAll.action?currentPage=${status.count }">${status.count }</a>
													</c:if>
												</c:forEach>
												<c:if test="${pageBean.currentPage < pageBean.totalPage}">
													<a
														href="${basePath }/wxUserlistAction_findAll.action?currentPage=${pageBean.currentPage +1}">下一页</a>
												</c:if>
												<c:if test="${pageBean.currentPage >= pageBean.totalPage}">
													<a href="javascript:;">下一页</a>
												</c:if>

												<a
													href="${basePath }/wxUserlistAction_findAll.action?currentPage=${pageBean.totalPage }">尾页</a>
												<input type="hidden" id="totalPage"
													value="${pageBean.totalPage }"> <span>跳至</span> <input
													type="text" id="pageGO" /> <a href="javascript:;"
													id="paegLinkGo1">GO</a>
											</div>
											<div class="right fr">
												<span class="now-num">当前第<b>${pageBean.currentPage }</b>页
												</span> <span class="toggle-num">共<b>${pageBean.totalPage }</b>页
												</span>
											</div>
										</div>

										<script type="text/javascript">
										       	$(document).on('click', '#paegLinkGo1', function() {
										       		var page = $('#pageGO').val();
										       		var totalPage = $('#totalPage').val()
										       		if(page >0 && page <= totalPage){
										       		window.location.href = "${basePath }/wxUserlistAction_findAll.action?currentPage="+page;
										       		}else{
										       			return false;
										       		}
										       	})
										    </script>
										<!-- 分页end	 -->
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- 浮层 -->
	<div class="crime-msk none">
		<div class="crime-dialog">
			<div class="title">
				<div class="left fl">
					<span>+ 新建对象</span>
				</div>
				<div class="right fr">
					<a href="javascript:;" class="crime-msk-close"></a>
				</div>
			</div>
			<div class="content">
				<form id="addWxUserFrom" action="" method="post">
					<input type="hidden" name="wxUser.id" value="" />
					<div class="card-check">
						<span>证件类型：</span> <select name="wxUser.credtype" id="">
							<c:forEach items="${credtypes}" var="credtype" varStatus="sts">
								<c:if test="${sts.index gt 0}">
									<option value="${sts.index }"
										<c:if test="${wxUser.credtype eq sts.index }">selected="selected"</c:if>>${credtype}</option>
								</c:if>
							</c:forEach>
						</select>
					</div>
					<div class="card-num">
						<span>证件号码：</span> <input type="text" name="wxUser.idcardno"
							id="idcardno" value="" /> <i>*</i>
					</div>
					<div class="card-name">
						<span>姓名：</span> <input type="text" name="wxUser.truename"
							id="truename" value="" /> <i>*</i>
					</div>
					<div class="zhongzu-check">
						<span>民族：</span> <select name="wxUser.nation" id="national-check">
							<c:forEach items="${nations}" var="nation" varStatus="sts">
								<c:if test="${sts.index gt 0}">
									<option value="${sts.index }"
										<c:if test="${wxUser.nation eq sts.index }">selected="selected"</c:if>>${nation}</option>
								</c:if>
							</c:forEach>
						</select>
					</div>
					<div class="birth-date">
						<span>出生日期：</span> <input type="text" name="wxUser.birthday"
							value="" class="layui-input" id="test1" lay-key="1">
						<!-- <i class="birth-date-icon"></i> -->
					</div>
					<div class="sex-check">
						<span>性别：</span> <select class="sexSelect" name="wxUser.sex" id="">
							<option value="1"
								<c:if test="${wxUser.sex eq 1 }">selected="selected"</c:if>>男</option>
							<option value="2"
								<c:if test="${wxUser.sex eq 2 }">selected="selected"</c:if>>女</option>
						</select>
					</div>
					<div class="age-check">
						<span>年龄：</span> <input type="text" name="wxUser.age" value=""
							class="age-check-input" />
					</div>
					<div class="city-check">
						<span>籍贯：</span>
						<div class="friend-select" data-toggle="distpicker">
							<div class="form-group">
								<select class="form-control" id="province1"
									name="wxUser.province"></select>
							</div>
							<div class="form-group">
								<select class="form-control" id="city1" name="wxUser.city"></select>
							</div>
							<div class="form-group">
								<select class="form-control" id="district1"
									name="wxUser.district"></select>
							</div>
							<br>
						</div>
					</div>
					<div class="city-check">
						<span>地址：</span> <input type="text" name="wxUser.address">
					</div>
					<div class="city-check">
						<span>联系电话：</span> <input type="text" name="wxUser.phone">
					</div>
					<div class="crime-msk-btn">
						<a href="javascript:;" class="crime-msk-save">保存</a> <a
							href="javascript:;" class="crime-msk-cancel">取消</a>
					</div>
				</form>
			</div>
		</div>
	</div>
                                                
	<!-- 底部 -->
<jsp:include page="common/bottom.jsp" flush="true" />

<script type="text/javascript" src="${basePath }/page/js/crime.js"></script>
<script type="text/javascript">
	laydate.render({
		elem : '#test1',
		value : new Date()
	});
	$('.birth-date-icon').click(function() {
		$(this).siblings('input').trigger('focus');
	})
</script>
<script type="text/javascript">
//保存判断
$('.crime-msk-save').click(function() {
    if($('.crime-dialog .content').find('input.error').length === 0) {
        //提交表单
    	/* 提交新增犯罪嫌疑人表单 */
    	//$('.crime-msk-save').click(function() {
    		var idcardno = $('#idcardno').val();
    		var truename = $('#truename').val();
    		if (!idcardno) {
    			showDialog('证件号不能为空');
    			return false;
    		}
    		if (!truename) {
    			showDialog('姓名不能为空');
    			return false;
    		}
    		$.ajax({
    			type : "POST",
    			url : "${basePath}/wxUserlistAction_add",
    			data : $('#addWxUserFrom').serialize(),
    			success : function(msg) {
    				setTimeout(function() {
    					$('.crime-msk').fadeOut(400);
    				}, 1000)
    				return window.location.href="${basePath }/wxUserlistAction_findAll";
    			}
    		});
    }
})	
	
// //删除
// $(document).on('click', '#crime-delete', function() {
// 	showDialogConfirm('是否删除该条信息？');
// })
//删除嫌疑人
function delUser(userid){
        	
	layer.open({
        content : "是否删除该条信息!",
        icon:3,
        btn : ['是','否'],
        yes : function(){
        	var url = "${basePath }/wxUserlistAction_deleteUserList?userid="+userid;
            $.post(url,function(data){
            	if(data == 0){
            		showDialogsucur2("请先删除和嫌疑人有关的评估记录");
            	}else{
            		return location.reload(); 
            	}	
            });
        },
    });
        }
//编辑
$(document).on('click', '#crime-edit', function() {
	//获取本行id
	var id = $(this).parent().siblings('.first-hook').find('input').val();
	$.ajax({
		type : "POST",
		url : "${basePath}/wxUserlistAction_toEdit",
		data : {
			"id" : id
		},
		traditional : true,
		success : function(data) {
			var json = eval("(" + data + ")");
			//给证件类型赋值
			$("[name='wxUser.credtype']").val(json.wxUser.credtype);
			/* var credtypeOpt = $("[name='wxUser.credtype'] option");
			for(var i=0;i<credtypeOpt.length;i++){
				if(credtypeOpt.eq(i).attr('value') == json.wxUser.credtype){
					credtypeOpt.eq(i).attr('selected','selected');
                }
			} */
			$("[name='wxUser.idcardno']").val(json.wxUser.idcardno);
			$("[name='wxUser.truename']").val(json.wxUser.truename);
			//给民族赋值
			$("[name='wxUser.nation']").val(json.wxUser.nation);
			/* var nationOpt = $("[name='wxUser.nation'] option");
			for(var i=0;i<nationOpt.length;i++){
				if(nationOpt.eq(i).attr('value') == json.wxUser.nation){
					nationOpt.eq(i).attr('selected','selected');
                }
			} */
			$("[name='wxUser.birthday']").val(json.birthday.substring(0,10));
			//给性别赋值
			$("[name='wxUser.sex']").val(json.wxUser.sex);
			$("[name='wxUser.age']").val(json.wxUser.age);
			$("[name='wxUser.id']").val(json.wxUser.id);
			//弹出浮层
			$('.crime-msk').fadeIn(400);
		}
	});
})
</script>
